#!/usr/bin/env python
# -*- coding:utf-8 -*-

# file:do_one_pickle.py
# author:张世航
# datetime:2024/11/12 22:46
# software: PyCharm
"""
练习:给定一个字典,保存了5个同学的学号,姓名,年龄;使用pickle模块将数据对象保存到文件中去;
"""
# import module your need

import pickle

# 定义字典数据
students = {
    "101": {"name": "张三", "age": 18},
    "102": {"name": "李四", "age": 19},
    "103": {"name": "王五", "age": 20},
    "104": {"name": "赵六", "age": 21},
    "105": {"name": "钱七", "age": 22}
}

# 使用pickle模块将数据对象保存到文件中
with open("students.pickle", "wb") as file:
    pickle.dump(students, file)